<template>
  <div class="content">
    <h2>后台系统账号申请列表</h2>
    <a-table :columns="columns" :data-source="dataSource">
      <template #name="{ text }">
        <a>{{ text }}</a>
      </template>
      <template #customTitle>
        <span>
          <smile-outlined />
          Name
        </span>
      </template>
      <template #action="{ record }">
        <span>
          <a @click="approve(record.u_id, record.u_tel, record.u_mail)">approve</a>
        </span>
      </template>
    </a-table>
  </div>
</template>
<script setup>
import { SmileOutlined, DownOutlined } from "@ant-design/icons-vue";
import { get, post, setLocalToken, tip } from "@/common";
import { reactive, ref } from "vue";
const columns = [
  {
    dataIndex: "u_name",
    key: "u_name",
    slots: {
      title: "customTitle",
      customRender: "name",
    },
  },
  {
    title: "ID",
    dataIndex: "u_id",
    key: "u_id",
  },
  {
    title: "Tel",
    dataIndex: "u_tel",
    key: "u_tel",
  },
  {
    title: "Mail",
    dataIndex: "u_mail",
    key: "u_mail",
  },
  {
    title: "Action",
    key: "action",
    slots: {
      customRender: "action",
    },
  },
];
const dataSource = ref([]);
const user = reactive({
  u_id : null,
  u_tel : null,
  u_mail : null,
});

const getList = () => {
  post("/admin/busermanage/getBUserApplyList").then((res) => {
    dataSource.value = res.data;
  });
};
const approve = (u_id, u_tel, u_mail) => {
  user.u_id = u_id;
  user.u_tel = u_tel;
  user.u_mail = u_mail;
  post("/admin/busermanage/new", user).then((res) => {
    tip.success("通过后台系统用户(id : " + user.u_id +" )注册申请");
    getList();
  });
};

getList();
</script>

<style scoped>
.content {
  padding-left: 10%;
  padding-right: 10%;
}
</style>